package com.bw.liuyushan.zhuangao4_mvptest1.Adapter;

import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

public class Fragment1Adapter extends FragmentStatePagerAdapter {
    ArrayList<Fragment> fragments1;
    ArrayList<String> strings;

    public Fragment1Adapter(FragmentManager fm, ArrayList<Fragment> fragments1, ArrayList<String> strings) {
        super(fm);
        this.fragments1 = fragments1;
        this.strings = strings;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments1.get(position);
    }

    @Override
    public int getCount() {
        return fragments1.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return strings.get(position);
    }

    //防止内存泄露
    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {

    }
}
